package com.sitecsys.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sitecsys.mapper.FTLUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

@Service
public class CheckAccountUtil {

    FTLUserMapper userMapper;

    @Autowired
    public void setUserMapper(FTLUserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Scheduled(fixedRate = 60000) // 每60秒执行一次
    public Boolean checkAccountStatus(String phone) throws IOException {

        // 在这里调用mapper的方法获取用户账户状态
            Integer flag = userMapper.CheckStatusByPhone(phone);
            System.out.println(flag);
            if (userMapper.CheckStatusByPhone(phone) == 0) {
                return false;
            }
            return true;
    }

}
